<script setup>
import { reactive } from 'vue'
import useViewEvent from '@/core/hooks/useViewEvent'
import brandApi from '@/api/goods/BrandApi'
import { errorImage } from '@/core/config/constant'

const state = reactive({ 
  visible: false,  
  loading: false, // 加载开关
})
// 表单结构
const original = {
  id: '',
  cnName: '',
  enName: '',
  logo: '',
  images: [],
  website: '',
  notes: '',
  summary: ''
}
// 表单数据
const formState = reactive({})

// 初始化数据
const { InitializeData } = useViewEvent({state: state, remoteFetchData: brandApi.getFormModelById, formState: formState, original: original })

//向父组件暴露方法和属性
defineExpose({ InitializeData })
</script>
<template>
  <a-drawer
    v-model:visible="state.visible"
    :title="`查看品牌信息`"
    placement="right"
    :width="'50%'">
    <template #extra>
      <a-button type="link" @click="state.visible=false">关闭</a-button>
    </template>
    <a-card hoverable>
      <a-spin :spinning="state.loading">
        <a-descriptions :column="1" bordered>
          <a-descriptions-item label="中文名称">{{ formState.cnName }}</a-descriptions-item>
          <a-descriptions-item label="英文名称">{{ formState.enName }}</a-descriptions-item>
          <a-descriptions-item label="LOGO">
            <a-image :width="100" :src="formState.logo" :fallback="errorImage" />
          </a-descriptions-item>
          <a-descriptions-item label="网址">{{ formState.website }}</a-descriptions-item>
          <a-descriptions-item label="品牌故事">{{ formState.summary }}</a-descriptions-item>
          <a-descriptions-item label="备注">{{ formState.notes }}</a-descriptions-item>
        </a-descriptions>
      </a-spin>
    </a-card>
  </a-drawer>
</template>